package com.atguigu.srb.core.controller.api;

import com.atguigu.srb.core.pojo.entity.Dict;
import com.atguigu.srb.core.result.R;
import com.atguigu.srb.core.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/core/dict")
@Api(tags = "前端的后台数据字典管理")
@Slf4j
public class WebDictController {
    @Autowired
    private DictService dictService;


    // 功能: 根据编码获取数据字典
    @ApiOperation("根据编码获取数据字典")
    @GetMapping("/findByDictCode/{dictCode}")
    public R findDictCode(@PathVariable("dictCode") @ApiParam("节点编码") String dictCode) {
            log.info("<<<---------------根据编码获取数据字典----->>>"+dictCode);
      List<Dict> dictList = dictService.findByDictCode(dictCode);

        return R.ok().data("dictList",dictList);
    }


}
